package com.lagou.pojo;

import com.lagou.sqlSession.SqlSession;

import javax.sql.DataSource;
import java.util.*;


public class Configuration {

    protected final Map<String, MappedStatement> mappedStatements = new StrictMap<MappedStatement>("Mapped Statements collection");
    //protected final Collection<CacheRefResolver> incompleteCacheRefs = new LinkedList<>();

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void setMappedStatementMap(Map<String, MappedStatement> mappedStatementMap) {
        this.mappedStatementMap = mappedStatementMap;
    }

    private DataSource dataSource;
    //key:statementid value：封装好的statement
    private Map<String,MappedStatement> mappedStatementMap =new HashMap<>();

    public Map<String, MappedStatement> getMappedStatementMap() {
        return mappedStatementMap;
    }

    public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
        //return mapperRegistry.getMapper(type, sqlSession);
        return  null;
    }

    public boolean hasStatement(String statementName) {
        return hasStatement(statementName, true);
    }

    public boolean hasStatement(String statementName, boolean validateIncompleteStatements) {
        if (validateIncompleteStatements) {

        }
        return mappedStatements.containsKey(statementName);
    }




    protected static class StrictMap<V> extends HashMap<String, V> {
        private final String name;
        public StrictMap(String name) {
            super();
            this.name = name;
        }
    }
}
